package com.fansm;

import java.util.function.*;

public class FunctionDemo {
    public static void main(String[] args) {
        Supplier<String> supplier = () -> "this is supplier demo";
        System.out.println(supplier.get());

        // 只有输入，没有输出
        Consumer<String> consumer = (i) -> System.out.println("please consumer data " + i);
        consumer.accept("123");

        Function<Integer, String> function = (i) -> "this is number "+ i;
        System.out.println(function.apply(123));

        UnaryOperator<Integer> unaryOperator = (i) -> i* i;
        System.out.println(unaryOperator.apply(2));

        BiFunction<Integer, Integer, String> biFunction = (i, j) -> i+"*"+j+"="+i*j;
        System.out.println(biFunction.apply(3, 8));
    }
}
